<?php
/*
Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
include_once("tokenizer.php");
include_once("token.php");
include_once("script_parser.php");

class script
{
	private static $semf_root;
	private $tokenizer;
	private $parser;
	private $script;
	private $tokens;
	private $project_home;
	
	private $parse_tree;
	
	public function __construct($script, $semf_root, $project_home, $description)
	{
		$this->script = $script;
		$this->semf_root = $semf_root;
		$this->tokenizer = new tokenizer($script, $project_home, $description);
		
		$this->tokens = $this->tokenizer->tokenize();
		foreach ($this->tokens as $token)
		{
			//echo "type: ".$token->type."; value: ".$token->value."\n";
		} 
		//print_r($this->tokens);
		
		$this->parser = new script_parser($this->tokens, $semf_root, $describtion);
		$this->project_home = $project_home;
		
		$this->parse_tree = NULL;
	}
	
	public function get_parse_tree()
	{
		$this->parse_tree = $this->parser->parse();
		//print_r($this->parse_tree);
		return $this->parse_tree;
	}
	
	public function get_tokens()
	{
		return $this->tokens;
	}
	
	public function get_errors()
	{
		return $this->parser->get_errors();
	}
}
?>